package com.rd.student.jike.class2.lihongming.StudentSystem;


import java.util.LinkedList;
import java.util.Scanner;

/**
 * @Auther:Heinrich
 * @Date:2023/7/12-07-12-12:33
 * @Description:com.rd.student.jike.class2.lihongming.StudentSystem
 * @version:1.0
 */
public class ConsoleTest {
    public static void main(String[] args) {
        LinkedList studentList = new LinkedList();
        Scanner scanner = new Scanner(System.in);

        studentList.add(new StudentG4("李宏鸣", "计科", "2班", "无", 80,2400));

        System.out.println("欢迎登陆学生管理系统！(按任意键开始)");
//        测试样例
//        Student LiHongMing = new Student("李宏鸣", "计科", "2班", "", 80);
        StudentG4 XueZhiXin = new StudentG4("薛志鑫", "计科", "2班", "", 66,3000);
        StudentG4 WangHaiXin = new StudentG4("王海鑫", "计科", "4班", "", 18,900);
        StudentG4 XiaYinYin = new StudentG4("夏银银", "计科", "4班", "", 18,300);
        StudentG4 WangXiangYang = new StudentG4("王向阳", "计科", "5班", "", 18,1200);
//      studentList.add(LiHongMing);
        studentList.add(XueZhiXin);
        studentList.add(WangHaiXin);
        studentList.add(XiaYinYin);
        studentList.add(WangXiangYang);
        studentList.add(new StudentG4("吴俊豪","计科","5班","69岁扶墙对抗",69,700));
        while (true){
            System.out.println(
                    "请按要求输入如下指令：\n"+
                            "0、查看所有小组成员\n" +
                            "1、新增小组成员\n" +
                            "2、移除小组成员\n" +
                            "3、根据班级查询成员列表\n" +
                            "4、根据专业查询成员列表 \n" +
                            "5、根据年龄查询成员列表 \n" +
                            "6、返回所有成员名字\n"+
                            "7、计算成员的平均年龄\n" +
                            "8、根据年龄范围返回成员列表\n"+
                            "9、退出系统"
            );
            String answer = scanner.next();
            switch (answer){
                case "0":
                    SystemMethod.showStudent(studentList);
                    break;
                case "1":
                    SystemMethod.addStudent(studentList);
                    break;
                case "2":
                    System.out.println("请输入要删除的学生的学号或姓名");
                    String name = scanner.next();
                    SystemMethod.deleteStudent(studentList,name);
                    break;
                case "3":
                    boolean flag = true;
                    do{SystemMethod.inquireCls(studentList);
                        System.out.println("是否继续查询,输入1继续查询");
                        if(!scanner.next().equals("1")){
                            flag = false;
                        }
                    }while (flag);
                    break;
                case "4":
                    System.out.println(SystemMethod.MajorInquir(studentList));
                    break;
                case "5":
                    System.out.println("请输入要查询的的年龄：\n" +"[输入-1返回年龄分布]");
                    String answer1 = scanner.next();
                    if(answer1.equals("-1")){
                        System.out.println(SystemMethod.ageQuery(studentList));
                    }else{
                        System.out.println(SystemMethod.ageMember(studentList,Integer.valueOf(answer1)));
                    }
                    break;
                case "6":
                    SystemMethod.getAllNames(studentList);
                    break;
                case "7":
                    SystemMethod.averageAge(studentList);
                    break;
                case "8":
                    System.out.println("请输入要查询的最小年龄");
                    int min = scanner.nextInt();
                    System.out.println("请输入要查询的最大年龄");
                    int max = scanner.nextInt();
                    SystemMethod.rangeAgeReturn(studentList,min,max);
                    break;
                case "9":
                    System.out.println("系统已退出");
                    return;
                default:
                    System.out.println("指令输入错误");
            }

        }
    }
}
